package leetcode.array;

import org.junit.Test;

import java.util.Arrays;
import java.util.HashSet;
import java.util.Set;

/**
 * @description: 删除有序数组中的重复项 2021-11-20
 * @author: cyy
 **/
public class Demo20211120_3 {

    public static void main(String[] args) {
        System.out.println("result:" + s());
    }

    public static int s() {
        int[] nums = {1, 1, 2};
        if (nums.length == 0) return 0;
        if (nums.length == 1) return nums[0];
        int p = 0;
        for (int q = 0; q < nums.length; q++) {
            if (nums[p] != nums[q]) {
                nums[p + 1] = nums[q];
                p++;
            }
        }
        return ++p;
    }
}
